package service.Impl;

import dao.VegetableImportDao;
import entity.MergeEntity;
import entity.PageEntity;
import service.VegetableImportService;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/11/10.
 */
public class VegetableImportImpl implements VegetableImportService{
  private VegetableImportDao vid=new VegetableImportDao();

    @Override
    //查询
    public List<MergeEntity> queryAll(PageEntity pe) {
        List<MergeEntity> list=null;
        try {
            list=vid.queryAll(pe);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            try {
                vid.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    @Override
    //得到总行数
    public int rows()  {
        int countRow=0;
        try {
            countRow=vid.pageCounts();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            try {
                vid.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return countRow;
    }


    @Override
    //删除
    public int delete(String id) {
        int r=0;
        try {
            r=vid.delete(id);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            try {
                vid.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return r;
    }

    @Override
    public int modify(String id1,float quantity,int typeid) {
       int r=0;
        try {
           r=vid.modify(id1,quantity,typeid);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            try {
                vid.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return r;
    }


}
